import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { User } from './User';

@Entity('chats')
export class Chat {
  @PrimaryGeneratedColumn()
  chat_id!: number;

  @Column()
  sender_id!: number;

  @Column()
  receiver_id!: number;

  @Column({ type: 'text' })
  message!: string;

  @Column({ type: 'enum', enum: ['text', 'image', 'file'], default: 'text' })
  type!: string;

  @CreateDateColumn()
  sent_at!: Date;

  @Column({ type: 'tinyint', default: 0 })
  is_read!: number;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'sender_id' })
  sender!: User;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'receiver_id' })
  receiver!: User;
} 